package com.work.straighttalk.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.facebook.drawee.view.SimpleDraweeView;
import com.hyphenate.chat.EMImageMessageBody;
import com.hyphenate.chat.EMMessage;
import com.work.straighttalk.R;
import com.work.straighttalk.bean.StraightTalkMessage;

import butterknife.Bind;

/**
 * Created by 朱相卿 on 16/3/19.
 */
public class ReceiveImageHolder extends BaseViewHolder<StraightTalkMessage> {
    @Bind(R.id.sd_chat_pic)
    SimpleDraweeView sdChatPic;

    public ReceiveImageHolder(Context context, ViewGroup root) {
        super(context, root, R.layout.item_chat_picture_receive);
    }

    @Override
    public void bindData(StraightTalkMessage message) {
        EMMessage emMessage = message.getEmMessage();
        EMImageMessageBody body = (EMImageMessageBody) emMessage.getBody();

        if (body.getLocalUrl() != null) {
            // String filePath = imgBody.getLocalUrl();
            String remotePath = body.getRemoteUrl();
            Uri uri = Uri.parse(remotePath);
            sdChatPic.setImageURI(uri);
        }
    }
}
